package com.hqyj.javaGraduation.hotel.service.Impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hqyj.javaGraduation.hotel.account.pojo.AccountUser;
import com.hqyj.javaGraduation.hotel.dao.HotelMemberMapper;
import com.hqyj.javaGraduation.hotel.service.HotelMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
public class HotelMemberServiceImpl implements HotelMemberService {
    @Autowired(required = false)
    private HotelMemberMapper hotelMemberMapper;

    @Override
    public HashMap<String, Object> memberList(AccountUser user) {
        HashMap<String, Object> map = new HashMap<>();
        HashMap map1 = new HashMap<>();

        IPage<AccountUser> page = new Page<>(user.getPage(),user.getRow());
        map1.put("role_name","member");

        IPage<AccountUser> memberList = hotelMemberMapper.getMember(page,map1);

        /* 当前页的集合 */
        map.put("info",memberList.getRecords());
        /* 获取总条数 */
        map.put("total",memberList.getTotal());
        /* 获取总页数 */
        map.put("totalPage",memberList.getPages());

        return map;
    }

    @Override
    public HashMap<String, Object> getCommonMemberList(AccountUser user) {
        HashMap<String, Object> map = new HashMap<>();
        HashMap map2 = new HashMap<>();

        IPage<AccountUser> page = new Page<>(user.getPage(),user.getRow());
        map2.put("user_member","普通会员");

        IPage<AccountUser> memberList = hotelMemberMapper.getMemberLevel(page,map2);

        /* 当前页的集合 */
        map.put("info",memberList.getRecords());
        /* 获取总条数 */
        map.put("total",memberList.getTotal());
        /* 获取总页数 */
        map.put("totalPage",memberList.getPages());

        return map;
    }

    @Override
    public HashMap<String, Object> getGoldMemberList(AccountUser user) {
        HashMap<String, Object> map = new HashMap<>();
        HashMap map2 = new HashMap<>();

        IPage<AccountUser> page = new Page<>(user.getPage(),user.getRow());
        map2.put("user_member","黄金会员");

        IPage<AccountUser> memberList = hotelMemberMapper.getMemberLevel(page,map2);

        /* 当前页的集合 */
        map.put("info",memberList.getRecords());
        /* 获取总条数 */
        map.put("total",memberList.getTotal());
        /* 获取总页数 */
        map.put("totalPage",memberList.getPages());

        return map;
    }

    @Override
    public HashMap<String, Object> getMasonryMemberList(AccountUser user) {
        HashMap<String, Object> map = new HashMap<>();
        HashMap map2 = new HashMap<>();

        IPage<AccountUser> page = new Page<>(user.getPage(),user.getRow());
        map2.put("user_member","砖石会员");

        IPage<AccountUser> memberList = hotelMemberMapper.getMemberLevel(page,map2);

        /* 当前页的集合 */
        map.put("info",memberList.getRecords());
        /* 获取总条数 */
        map.put("total",memberList.getTotal());
        /* 获取总页数 */
        map.put("totalPage",memberList.getPages());

        return map;
    }
}
